package com.safe.text;

import com.safe.text.R;
import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;
import com.markupartist.android.widget.ActionBar;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.preference.PreferenceManager;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MainActivity extends BaseActivity {
	static TextView serviceStatus;

	StoredData db = new StoredData(this);
	static Button btnUpdate;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	    AdView adView = (AdView)this.findViewById(R.id.adView);
	    adView.loadAd(new AdRequest());
		populateTable();

		currentActivity = this;
		ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);
		actionBar.setTitle(R.string.app_name);
		actionBar.setHomeAction(new HomeAction());
		actionBar.addAction(new AboutAction());
		actionBar.addAction(new SettingsAction());
		actionBar.addAction(new RefreshAction());
		actionBar.setOnTitleClickListener(new OnClickListener() {
			public void onClick(View v) {
				// Your code here
				// Intent home = new Intent(MainActivity.this,
				// MainActivity.class);
				// finish();
				// startActivity(home);
			}
		});

		SharedPreferences prefs = PreferenceManager
				.getDefaultSharedPreferences(this);
		phoneNumber = prefs.getString("phoneNumber", "");
		emailAddress = prefs.getString("emailAddress", "");
		serviceStatus = (TextView) findViewById(R.id.txtServiceStatus);
		if (isMyServiceRunning()) {
			serviceStatus.setText("SafeText is enabled");
		} else {
			serviceStatus.setText("SafeText is disabled");
		}
		
		
	}
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.e("resultCode", ""+resultCode);
Log.e("requestCode", ""+requestCode);
		if (requestCode == 7) {
				getDrivingHist hist = new getDrivingHist();
				hist.execute(-1);
		}

		}//onAcrivityResult
	public void onResume() {
		currentActivity = this;
		super.onResume();
	}
	


}
